/**********************************************************************
  The MIT License (MIT)
  Copyright (c) 2012 sunriseyuen

  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files
  (the "Software"), to deal in the Software without restriction,
  including without limitation the rights to use, copy, modify, merge,
  publish, distribute, sublicense, and/or sell copies of the Software,
  and to permit persons to whom the Software is furnished to do so,
  subject to the following conditions:

  The above copyright notice and this permission notice shall be included
  in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
  THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 ***********************************************************************/

	#define _DEF_CCY_CODE
	#define _ZZDEBUG
	#define _PROJ_DC

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

#region Using directives

using System;
using System.Text;
using System.IO;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using System.Web.UI;

using Muki.Framework;
using Muki.Framework.UI;
using Muki.Framework.Business;
using Muki.Framework.Util;
using Muki.UserDefine;
using Muki.Entity;
using Dot.StreamObject;

#endregion

namespace Muki.UserPanel
{

	public class UID02001BUI:BaseAction
	{
		public UID02001BUI()
		{
		}

		public override void OnRetrieve(string cDefined_Code)
		{
				if (!_Retrieve(cDefined_Code))
				{
					if (cDefined_Code=="")
					{
						_UID02001BV.Exceptions.Clear();
						if (!_Retrieve("MN"))
						{
							if (!_Retrieve("MP")){
								this.OnDefault();
							}
						}
					}
				}
		}

		private bool _Retrieve(string cDefined_Code)
		{
			VContexts _VContexts=new VContexts();

			_VContexts.setValue("UDEF_CODE",cDefined_Code);


				UID02001BE _Entity=_UID02001BV.Entity;

				if (cDefined_Code=="PICKUP") {
					Spliter _PK_Spliter      = new Spliter(_UID02001BV.ZZEventOpts);
					_PK_Spliter.Separator    = '|';
					_PK_Spliter.Separatorb   = '=';
					_PK_Spliter.DecodeBase64 = true;
					_PK_Spliter.Split();

							_Entity.UID_DT=_PK_Spliter["UID_DT"];
				}else if (cDefined_Code=="ACTIVETAB") {
					_UID02001BV.ZZLookup               = _UID02001BV.ZZPanels["UID02001B","lookup"];
					_UID02001BV.ZZEventStage           = _UID02001BV.ZZPanels["UID02001B","stage"];
					_UID02001BV.CellsPanel.VIEW_STATUS_DATA = _UID02001BV.ZZPanels.getVContexts("UID02001B","view_status");

									_Entity.UID_CODE=_UID02001BV.ZZPanels["UID02001A","PK_UID_CODE"];
				}else{
					_VContexts.setValue("LOOKUP_DATA",_UID02001BV.ZZLookup);

					_UID02001BV.ZZPanels["UID02001B","lookup"] = _UID02001BV.ZZLookup;
					_UID02001BV.ZZPanels["UID02001B","table"]  = "ZZLOOKUP_ANY_COLUMN";
				}

								_Entity.UID_CODE=_UID02001BV.ZZPanels["UID02001A","PK_UID_CODE"];

				UID02001BE _NewEntity=_UID02001BM.Retrieves(_VContexts,_Entity);

				if (_NewEntity.DATA_STATUS_CODE=="Verified") {
					_UID02001BV.Entity             = _NewEntity;
					_UID02001BV.ZZVIEW_STATUS_CODE = _UID02001BV.ZZEventStatus;
					_UID02001BV.ZZVIEW_STAGEU_CODE = _UID02001BV.ZZEventStage;
				}
				_UID02001BV.Exceptions=_NewEntity.Exceptions;
				return _NewEntity.DATA_STATUS_CODE=="Verified";
		}

		public override void OnDefault()
		{
			UID02001BE _Entity=new UID02001BE();

						_Entity.UID_CODE=_UID02001BV.ZZPanels["UID02001A","PK_UID_CODE"];

			UID02001BE _NewEntity=_UID02001BM.Default(_Entity);

			if (_NewEntity.Exceptions.Count==0) {
				this.Trans.Commit();

				_UID02001BV.Entity             = _NewEntity;
				_UID02001BV.ZZVIEW_STATUS_CODE = _UID02001BV.ZZEventStatus;
				_UID02001BV.ZZVIEW_STAGEU_CODE = _UID02001BV.ZZEventStage;
			}
			_UID02001BV.Exceptions=_NewEntity.Exceptions;

		}

		public override void OnUpdate()
		{

			UID02001BE _NewEntity=_UID02001BM.Update(_UID02001BV.Entity);

			if (_NewEntity.Exceptions.Count==0){
				this.Trans.Commit();

				_UID02001BV.Entity             = _NewEntity;
				_UID02001BV.ZZVIEW_STATUS_CODE = _UID02001BV.ZZEventStatus;
				_UID02001BV.ZZVIEW_STAGEU_CODE = _UID02001BV.ZZEventStage;
			}
			_UID02001BV.Exceptions=_NewEntity.Exceptions;

			ZZTrace.Debug(ZFILE_NAME,"...OnUpdate...Count "+_NewEntity.Exceptions.Count);

		}		

		public override void OnAddNew()
		{

			UID02001BE _NewEntity=_UID02001BM.AddNew(_UID02001BV.Entity);

			//ZZTrace.Debug(ZFILE_NAME,"...OnAddNew...DATA_STATUS_CODE2 "+_NewEntity.DATA_STATUS_CODE);

			foreach (LogisticException tmp in _NewEntity.Exceptions)
			{
				ZZTrace.Debug(ZFILE_NAME,tmp);
			}

			//ZZTrace.Debug(ZFILE_NAME,"...OnAddNew...Count "+_NewEntity.Exceptions.Count);

			if (_NewEntity.Exceptions.Count==0) {
				this.Trans.Commit();

				_UID02001BV.Entity             = _NewEntity;
				_UID02001BV.ZZVIEW_STATUS_CODE = _UID02001BV.ZZEventStatus;
				_UID02001BV.ZZVIEW_STAGEU_CODE = _UID02001BV.ZZEventStage;
			}
			_UID02001BV.Exceptions=_NewEntity.Exceptions;

		}

		public override void OnChange(string cArg_Code)
		{
			if (cArg_Code!="") {
				_UID02001BV.ZZVIEW_STATUS_CODE = _UID02001BV.ZZEventStatus;
				_UID02001BV.ZZVIEW_STAGEU_CODE = _UID02001BV.ZZEventStage;
			}else{
				//ZZTrace.Debug(ZFILE_NAME,"PK_DATA "+_UID02001BV.ZZLOGON_MODE);

				ZZTrace.Debug(ZFILE_NAME,"ZZLOGON_LANG="+this.ZZLOGON_LANG);

				MessageInfo oMessageInfo  = new MessageInfo();
				oMessageInfo.DbName       = this.DbName;
				oMessageInfo.Trans        = this.Trans;
				oMessageInfo.ZZLOGON_LANG = this.ZZLOGON_LANG;
				oMessageInfo.ZZLOGON_SSD  = this.ZZLOGON_SSD;

				int _SUCCESS=0;
				int _FAILURE=0;
				if (_UID02001BV.ZZLOGON_MODE=="B") {

					_UID02001BV.ZZWxf.MoveFirst();
					while (!_UID02001BV.ZZWxf.EOF) {
						_UID02001BV.ZZWxf.Operation="P";
						_UID02001BV.ZZWxf.Reference="";
						
						VContexts _VContexts=new VContexts();

						_VContexts.setValue("UDEF_CODE","READ");

						//ZZTrace.Debug(ZFILE_NAME,"PK_DATA "+_UID02001BV.ZZWxf.PK_DATA);
						bool Verified=false;
						UID02001BE _NewEntity=null;
						if (_UID02001BV.ZZWxf.PK_DATA!=""){

							Spliter _PK_Spliter      = new Spliter(_UID02001BV.ZZWxf.PK_DATA);
							_PK_Spliter.Separator    = '|';
							_PK_Spliter.Separatorb   = '=';
							_PK_Spliter.DecodeBase64 = true;
							_PK_Spliter.Split();

							UID02001BE _Entity=_UID02001BV.Entity;

									_Entity.UID_DT=_PK_Spliter["UID_DT"];

											if (_UID02001BV.ZZPanels["UID02001A","PK_UID_CODE"]!="")
											{
												_Entity.UID_CODE=_UID02001BV.ZZPanels["UID02001A","PK_UID_CODE"];
											}

							_NewEntity=_UID02001BM.Retrieves(_VContexts,_Entity);

							if (_NewEntity.DATA_STATUS_CODE=="Verified") 
							{
								Verified=true;
								foreach (AttributeMapping _AttributeMapping in _UID02001BV.ZZWxf.Fields)
								{
									if (_AttributeMapping.STATUS_CODE.IndexOf("UPDATE")>=0) {
												if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NAME") {
														_NewEntity.COLUMN_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NULLABLE") {
														_NewEntity.COLUMN_NULLABLE=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.BASE_COLUMN_NAME") {
														_NewEntity.BASE_COLUMN_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.BASE_TABLE_NAME") {
														_NewEntity.BASE_TABLE_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.LNK_COLUMN_NAME") {
														_NewEntity.LNK_COLUMN_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.OPT_CODE") {
														_NewEntity.OPT_CODE=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VERFY") {
														_NewEntity.RELY_VERFY=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_DEFAULT") {
														_NewEntity.RELY_DEFAULT=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VIEW") {
														_NewEntity.RELY_VIEW=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.NEW_LINE") {
														_NewEntity.NEW_LINE=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.NEW_CELL") {
														_NewEntity.NEW_CELL=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.ROWS_SPAN") {
														_NewEntity.ROWS_SPAN=_UID02001BV.ZZWxf.getInteger(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.COLS_SPAN") {
														_NewEntity.COLS_SPAN=_UID02001BV.ZZWxf.getInteger(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.ACTIVE_BIT") {
														_NewEntity.ACTIVE_BIT=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="ZUPRGDTM.LINE_REVEAL") {
														_NewEntity.LINE_REVEAL=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
												}
									}
								}
							}else{
								_NewEntity=_Entity;
							}
						}
						if (Verified)
						{
								foreach (LogisticException tmp in _NewEntity.Exceptions)
								{
									ZZTrace.Debug(ZFILE_NAME,tmp);
								}

								UID02001BE _NewEntity2=_UID02001BM.Update(_NewEntity);
								
								string cMsg="";
								foreach (LogisticException tmp in _NewEntity2.Exceptions)
								{
										cMsg=cMsg+oMessageInfo.Message("UID02001B",tmp)+"||";
								}

								if (_NewEntity2.Exceptions.Count==0)
								{
									UID02001BE _NewEntity3=_UID02001BM.Retrieves(_VContexts,_NewEntity2);

									foreach (LogisticException tmp in _NewEntity3.Exceptions)
									{
										ZZTrace.Debug(ZFILE_NAME,tmp);
									}

									if (_NewEntity3.DATA_STATUS_CODE=="Verified")
									{
										_SUCCESS++;
										_UID02001BV.ZZWxf.Operation="Y";
									}else{
										_UID02001BV.ZZWxf.Operation="R";
										_FAILURE++;
									}

									foreach (AttributeMapping _AttributeMapping in _UID02001BV.ZZWxf.Fields)
									{
													if (_AttributeMapping.Name=="ZUPRGDTM.UID_CODE") {
														_UID02001BV.ZZWxf["ZUPRGDTM.UID_CODE"]=_NewEntity3.UID_CODE;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.SERIAL_NO") {
														_UID02001BV.ZZWxf["ZUPRGDTM.SERIAL_NO"]=_NewEntity3.SERIAL_NO;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.TABLE_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.TABLE_NAME"]=_NewEntity3.TABLE_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.COLUMN_NAME"]=_NewEntity3.COLUMN_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NULLABLE") {
														_UID02001BV.ZZWxf["ZUPRGDTM.COLUMN_NULLABLE"]=_NewEntity3.COLUMN_NULLABLE;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.LABEL_ID") {
														_UID02001BV.ZZWxf["ZUPRGDTM.LABEL_ID"]=_NewEntity3.LABEL_ID;
													}
													if (_AttributeMapping.Name=="VARIABLE.UID_ENG_NAME") {
														_UID02001BV.ZZWxf["VARIABLE.UID_ENG_NAME"]=_NewEntity3.UID_ENG_NAME;
													}
													if (_AttributeMapping.Name=="VARIABLE.UID_CHS_NAME") {
														_UID02001BV.ZZWxf["VARIABLE.UID_CHS_NAME"]=_NewEntity3.UID_CHS_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.BASE_COLUMN_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.BASE_COLUMN_NAME"]=_NewEntity3.BASE_COLUMN_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.BASE_TABLE_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.BASE_TABLE_NAME"]=_NewEntity3.BASE_TABLE_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.LNK_COLUMN_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.LNK_COLUMN_NAME"]=_NewEntity3.LNK_COLUMN_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.OPT_CODE") {
														_UID02001BV.ZZWxf["ZUPRGDTM.OPT_CODE"]=_NewEntity3.OPT_CODE;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VERFY") {
														_UID02001BV.ZZWxf["ZUPRGDTM.RELY_VERFY"]=_NewEntity3.RELY_VERFY;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.RELY_DEFAULT") {
														_UID02001BV.ZZWxf["ZUPRGDTM.RELY_DEFAULT"]=_NewEntity3.RELY_DEFAULT;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VIEW") {
														_UID02001BV.ZZWxf["ZUPRGDTM.RELY_VIEW"]=_NewEntity3.RELY_VIEW;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.NEW_LINE") {
														_UID02001BV.ZZWxf["ZUPRGDTM.NEW_LINE"]=_NewEntity3.NEW_LINE;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.NEW_CELL") {
														_UID02001BV.ZZWxf["ZUPRGDTM.NEW_CELL"]=_NewEntity3.NEW_CELL;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.ROWS_SPAN") {
														_UID02001BV.ZZWxf["ZUPRGDTM.ROWS_SPAN"]=_NewEntity3.ROWS_SPAN;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.COLS_SPAN") {
														_UID02001BV.ZZWxf["ZUPRGDTM.COLS_SPAN"]=_NewEntity3.COLS_SPAN;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.ACTIVE_BIT") {
														_UID02001BV.ZZWxf["ZUPRGDTM.ACTIVE_BIT"]=_NewEntity3.ACTIVE_BIT;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.LINE_REVEAL") {
														_UID02001BV.ZZWxf["ZUPRGDTM.LINE_REVEAL"]=_NewEntity3.LINE_REVEAL;
													}
									}
								}else{
									_FAILURE++;
									_UID02001BV.ZZWxf.Reference=cMsg;
									_UID02001BV.ZZWxf.Operation="F";
									
									foreach (AttributeMapping _AttributeMapping in _UID02001BV.ZZWxf.Fields)
									{
													if (_AttributeMapping.Name=="ZUPRGDTM.UID_CODE") {
														_UID02001BV.ZZWxf["ZUPRGDTM.UID_CODE"]=_NewEntity2.UID_CODE;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.SERIAL_NO") {
														_UID02001BV.ZZWxf["ZUPRGDTM.SERIAL_NO"]=_NewEntity2.SERIAL_NO;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.TABLE_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.TABLE_NAME"]=_NewEntity2.TABLE_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.COLUMN_NAME"]=_NewEntity2.COLUMN_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NULLABLE") {
														_UID02001BV.ZZWxf["ZUPRGDTM.COLUMN_NULLABLE"]=_NewEntity2.COLUMN_NULLABLE;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.LABEL_ID") {
														_UID02001BV.ZZWxf["ZUPRGDTM.LABEL_ID"]=_NewEntity2.LABEL_ID;
													}
													if (_AttributeMapping.Name=="VARIABLE.UID_ENG_NAME") {
														_UID02001BV.ZZWxf["VARIABLE.UID_ENG_NAME"]=_NewEntity2.UID_ENG_NAME;
													}
													if (_AttributeMapping.Name=="VARIABLE.UID_CHS_NAME") {
														_UID02001BV.ZZWxf["VARIABLE.UID_CHS_NAME"]=_NewEntity2.UID_CHS_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.BASE_COLUMN_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.BASE_COLUMN_NAME"]=_NewEntity2.BASE_COLUMN_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.BASE_TABLE_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.BASE_TABLE_NAME"]=_NewEntity2.BASE_TABLE_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.LNK_COLUMN_NAME") {
														_UID02001BV.ZZWxf["ZUPRGDTM.LNK_COLUMN_NAME"]=_NewEntity2.LNK_COLUMN_NAME;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.OPT_CODE") {
														_UID02001BV.ZZWxf["ZUPRGDTM.OPT_CODE"]=_NewEntity2.OPT_CODE;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VERFY") {
														_UID02001BV.ZZWxf["ZUPRGDTM.RELY_VERFY"]=_NewEntity2.RELY_VERFY;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.RELY_DEFAULT") {
														_UID02001BV.ZZWxf["ZUPRGDTM.RELY_DEFAULT"]=_NewEntity2.RELY_DEFAULT;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VIEW") {
														_UID02001BV.ZZWxf["ZUPRGDTM.RELY_VIEW"]=_NewEntity2.RELY_VIEW;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.NEW_LINE") {
														_UID02001BV.ZZWxf["ZUPRGDTM.NEW_LINE"]=_NewEntity2.NEW_LINE;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.NEW_CELL") {
														_UID02001BV.ZZWxf["ZUPRGDTM.NEW_CELL"]=_NewEntity2.NEW_CELL;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.ROWS_SPAN") {
														_UID02001BV.ZZWxf["ZUPRGDTM.ROWS_SPAN"]=_NewEntity2.ROWS_SPAN;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.COLS_SPAN") {
														_UID02001BV.ZZWxf["ZUPRGDTM.COLS_SPAN"]=_NewEntity2.COLS_SPAN;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.ACTIVE_BIT") {
														_UID02001BV.ZZWxf["ZUPRGDTM.ACTIVE_BIT"]=_NewEntity2.ACTIVE_BIT;
													}
													if (_AttributeMapping.Name=="ZUPRGDTM.LINE_REVEAL") {
														_UID02001BV.ZZWxf["ZUPRGDTM.LINE_REVEAL"]=_NewEntity2.LINE_REVEAL;
													}
									}
								}
							//}
						}else{
							if (_NewEntity==null)
							{
								_NewEntity=new UID02001BE();
							}
							
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_CODE=1["+_NewEntity.UID_CODE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_DT=1["+_NewEntity.UID_DT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.SERIAL_NO=1["+_NewEntity.SERIAL_NO+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.TABLE_NAME=1["+_NewEntity.TABLE_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLUMN_NAME=1["+_NewEntity.COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLUMN_NULLABLE=1["+_NewEntity.COLUMN_NULLABLE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LABEL_ID=1["+_NewEntity.LABEL_ID+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_ENG_NAME=1["+_NewEntity.UID_ENG_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_CHS_NAME=1["+_NewEntity.UID_CHS_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.BASE_COLUMN_NAME=1["+_NewEntity.BASE_COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.BASE_TABLE_NAME=1["+_NewEntity.BASE_TABLE_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LNK_COLUMN_NAME=1["+_NewEntity.LNK_COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.OPT_CODE=1["+_NewEntity.OPT_CODE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_VERFY=1["+_NewEntity.RELY_VERFY+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_DEFAULT=1["+_NewEntity.RELY_DEFAULT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_VIEW=1["+_NewEntity.RELY_VIEW+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.NEW_LINE=1["+_NewEntity.NEW_LINE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.NEW_CELL=1["+_NewEntity.NEW_CELL+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.ROWS_SPAN=1["+_NewEntity.ROWS_SPAN+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLS_SPAN=1["+_NewEntity.COLS_SPAN+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.ACTIVE_BIT=1["+_NewEntity.ACTIVE_BIT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LINE_REVEAL=1["+_NewEntity.LINE_REVEAL+"]");

							foreach (AttributeMapping _AttributeMapping in _UID02001BV.ZZWxf.Fields)
							{
								if (_AttributeMapping.STATUS_CODE.IndexOf("UPDATE")>=0 || _AttributeMapping.STATUS_CODE.IndexOf("ADDNEW")>=0)
								{
											if (_AttributeMapping.Name=="ZUPRGDTM.UID_CODE") {
													_NewEntity.UID_CODE=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.UID_DT") {
													_NewEntity.UID_DT=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.SERIAL_NO") {
													_NewEntity.SERIAL_NO=_UID02001BV.ZZWxf.getInteger(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.TABLE_NAME") {
													_NewEntity.TABLE_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NAME") {
													_NewEntity.COLUMN_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NULLABLE") {
													_NewEntity.COLUMN_NULLABLE=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.LABEL_ID") {
													_NewEntity.LABEL_ID=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.BASE_COLUMN_NAME") {
													_NewEntity.BASE_COLUMN_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.BASE_TABLE_NAME") {
													_NewEntity.BASE_TABLE_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.LNK_COLUMN_NAME") {
													_NewEntity.LNK_COLUMN_NAME=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.OPT_CODE") {
													_NewEntity.OPT_CODE=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VERFY") {
													_NewEntity.RELY_VERFY=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.RELY_DEFAULT") {
													_NewEntity.RELY_DEFAULT=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VIEW") {
													_NewEntity.RELY_VIEW=_UID02001BV.ZZWxf.getValue(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.NEW_LINE") {
													_NewEntity.NEW_LINE=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.NEW_CELL") {
													_NewEntity.NEW_CELL=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.ROWS_SPAN") {
													_NewEntity.ROWS_SPAN=_UID02001BV.ZZWxf.getInteger(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.COLS_SPAN") {
													_NewEntity.COLS_SPAN=_UID02001BV.ZZWxf.getInteger(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.ACTIVE_BIT") {
													_NewEntity.ACTIVE_BIT=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
											}
											if (_AttributeMapping.Name=="ZUPRGDTM.LINE_REVEAL") {
													_NewEntity.LINE_REVEAL=_UID02001BV.ZZWxf.getBoolean(_AttributeMapping.Name);
											}
								}
							}
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_CODE=2["+_NewEntity.UID_CODE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_DT=2["+_NewEntity.UID_DT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.SERIAL_NO=2["+_NewEntity.SERIAL_NO+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.TABLE_NAME=2["+_NewEntity.TABLE_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLUMN_NAME=2["+_NewEntity.COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLUMN_NULLABLE=2["+_NewEntity.COLUMN_NULLABLE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LABEL_ID=2["+_NewEntity.LABEL_ID+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_ENG_NAME=2["+_NewEntity.UID_ENG_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_CHS_NAME=2["+_NewEntity.UID_CHS_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.BASE_COLUMN_NAME=2["+_NewEntity.BASE_COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.BASE_TABLE_NAME=2["+_NewEntity.BASE_TABLE_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LNK_COLUMN_NAME=2["+_NewEntity.LNK_COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.OPT_CODE=2["+_NewEntity.OPT_CODE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_VERFY=2["+_NewEntity.RELY_VERFY+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_DEFAULT=2["+_NewEntity.RELY_DEFAULT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_VIEW=2["+_NewEntity.RELY_VIEW+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.NEW_LINE=2["+_NewEntity.NEW_LINE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.NEW_CELL=2["+_NewEntity.NEW_CELL+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.ROWS_SPAN=2["+_NewEntity.ROWS_SPAN+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLS_SPAN=2["+_NewEntity.COLS_SPAN+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.ACTIVE_BIT=2["+_NewEntity.ACTIVE_BIT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LINE_REVEAL=2["+_NewEntity.LINE_REVEAL+"]");

											if (_UID02001BV.ZZPanels["UID02001A","PK_UID_CODE"]!="")
											{
												_NewEntity.UID_CODE=_UID02001BV.ZZPanels["UID02001A","PK_UID_CODE"];
											}

										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_CODE=3["+_NewEntity.UID_CODE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_DT=3["+_NewEntity.UID_DT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.SERIAL_NO=3["+_NewEntity.SERIAL_NO+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.TABLE_NAME=3["+_NewEntity.TABLE_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLUMN_NAME=3["+_NewEntity.COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLUMN_NULLABLE=3["+_NewEntity.COLUMN_NULLABLE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LABEL_ID=3["+_NewEntity.LABEL_ID+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_ENG_NAME=3["+_NewEntity.UID_ENG_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.UID_CHS_NAME=3["+_NewEntity.UID_CHS_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.BASE_COLUMN_NAME=3["+_NewEntity.BASE_COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.BASE_TABLE_NAME=3["+_NewEntity.BASE_TABLE_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LNK_COLUMN_NAME=3["+_NewEntity.LNK_COLUMN_NAME+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.OPT_CODE=3["+_NewEntity.OPT_CODE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_VERFY=3["+_NewEntity.RELY_VERFY+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_DEFAULT=3["+_NewEntity.RELY_DEFAULT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.RELY_VIEW=3["+_NewEntity.RELY_VIEW+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.NEW_LINE=3["+_NewEntity.NEW_LINE+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.NEW_CELL=3["+_NewEntity.NEW_CELL+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.ROWS_SPAN=3["+_NewEntity.ROWS_SPAN+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.COLS_SPAN=3["+_NewEntity.COLS_SPAN+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.ACTIVE_BIT=3["+_NewEntity.ACTIVE_BIT+"]");
										ZZTrace.Debug(ZFILE_NAME,"_NewEntity.LINE_REVEAL=3["+_NewEntity.LINE_REVEAL+"]");

							UID02001BE _NewEntity7=_UID02001BM.AddNew(_NewEntity);

							string cMsg="";
							foreach (LogisticException tmp in _NewEntity7.Exceptions)
							{
									cMsg=cMsg+oMessageInfo.Message("UID02001B",tmp)+"||";
							}

							if (_NewEntity7.Exceptions.Count==0) {
								UID02001BE _NewEntity8=_UID02001BM.Retrieves(_VContexts,_NewEntity7);
								cMsg="";
								foreach (LogisticException tmp in _NewEntity8.Exceptions)
								{
									cMsg=cMsg+oMessageInfo.Message("UID02001B",tmp)+"||";
									ZZTrace.Debug(ZFILE_NAME,tmp);
								}

								if (_NewEntity8.DATA_STATUS_CODE=="Verified") {
									_SUCCESS++;
									_UID02001BV.ZZWxf.PK_DATA=_NewEntity8.PK_DATA;
									_UID02001BV.ZZWxf.Operation="Y";
								}else{
									_UID02001BV.ZZWxf.Reference=cMsg;
									_UID02001BV.ZZWxf.Operation="R";
									_FAILURE++;
								}

								foreach (AttributeMapping _AttributeMapping in _UID02001BV.ZZWxf.Fields)
								{
												if (_AttributeMapping.Name=="ZUPRGDTM.UID_CODE") {
													_UID02001BV.ZZWxf["ZUPRGDTM.UID_CODE"]=_NewEntity8.UID_CODE;
												}


												if (_AttributeMapping.Name=="ZUPRGDTM.SERIAL_NO") {
													_UID02001BV.ZZWxf["ZUPRGDTM.SERIAL_NO"]=_NewEntity8.SERIAL_NO;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.TABLE_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.TABLE_NAME"]=_NewEntity8.TABLE_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.COLUMN_NAME"]=_NewEntity8.COLUMN_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NULLABLE") {
													_UID02001BV.ZZWxf["ZUPRGDTM.COLUMN_NULLABLE"]=_NewEntity8.COLUMN_NULLABLE;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.LABEL_ID") {
													_UID02001BV.ZZWxf["ZUPRGDTM.LABEL_ID"]=_NewEntity8.LABEL_ID;
												}

												if (_AttributeMapping.Name=="VARIABLE.UID_ENG_NAME") {
													_UID02001BV.ZZWxf["VARIABLE.UID_ENG_NAME"]=_NewEntity8.UID_ENG_NAME;
												}

												if (_AttributeMapping.Name=="VARIABLE.UID_CHS_NAME") {
													_UID02001BV.ZZWxf["VARIABLE.UID_CHS_NAME"]=_NewEntity8.UID_CHS_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.BASE_COLUMN_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.BASE_COLUMN_NAME"]=_NewEntity8.BASE_COLUMN_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.BASE_TABLE_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.BASE_TABLE_NAME"]=_NewEntity8.BASE_TABLE_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.LNK_COLUMN_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.LNK_COLUMN_NAME"]=_NewEntity8.LNK_COLUMN_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.OPT_CODE") {
													_UID02001BV.ZZWxf["ZUPRGDTM.OPT_CODE"]=_NewEntity8.OPT_CODE;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VERFY") {
													_UID02001BV.ZZWxf["ZUPRGDTM.RELY_VERFY"]=_NewEntity8.RELY_VERFY;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_DEFAULT") {
													_UID02001BV.ZZWxf["ZUPRGDTM.RELY_DEFAULT"]=_NewEntity8.RELY_DEFAULT;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VIEW") {
													_UID02001BV.ZZWxf["ZUPRGDTM.RELY_VIEW"]=_NewEntity8.RELY_VIEW;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.NEW_LINE") {
													_UID02001BV.ZZWxf["ZUPRGDTM.NEW_LINE"]=_NewEntity8.NEW_LINE;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.NEW_CELL") {
													_UID02001BV.ZZWxf["ZUPRGDTM.NEW_CELL"]=_NewEntity8.NEW_CELL;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.ROWS_SPAN") {
													_UID02001BV.ZZWxf["ZUPRGDTM.ROWS_SPAN"]=_NewEntity8.ROWS_SPAN;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.COLS_SPAN") {
													_UID02001BV.ZZWxf["ZUPRGDTM.COLS_SPAN"]=_NewEntity8.COLS_SPAN;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.ACTIVE_BIT") {
													_UID02001BV.ZZWxf["ZUPRGDTM.ACTIVE_BIT"]=_NewEntity8.ACTIVE_BIT;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.LINE_REVEAL") {
													_UID02001BV.ZZWxf["ZUPRGDTM.LINE_REVEAL"]=_NewEntity8.LINE_REVEAL;
												}

								}

							}else{
								_FAILURE++;
								foreach (AttributeMapping _AttributeMapping in _UID02001BV.ZZWxf.Fields)
								{
												if (_AttributeMapping.Name=="ZUPRGDTM.UID_CODE") {
													_UID02001BV.ZZWxf["ZUPRGDTM.UID_CODE"]=_NewEntity7.UID_CODE;
												}


												if (_AttributeMapping.Name=="ZUPRGDTM.SERIAL_NO") {
													_UID02001BV.ZZWxf["ZUPRGDTM.SERIAL_NO"]=_NewEntity7.SERIAL_NO;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.TABLE_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.TABLE_NAME"]=_NewEntity7.TABLE_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.COLUMN_NAME"]=_NewEntity7.COLUMN_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.COLUMN_NULLABLE") {
													_UID02001BV.ZZWxf["ZUPRGDTM.COLUMN_NULLABLE"]=_NewEntity7.COLUMN_NULLABLE;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.LABEL_ID") {
													_UID02001BV.ZZWxf["ZUPRGDTM.LABEL_ID"]=_NewEntity7.LABEL_ID;
												}

												if (_AttributeMapping.Name=="VARIABLE.UID_ENG_NAME") {
													_UID02001BV.ZZWxf["VARIABLE.UID_ENG_NAME"]=_NewEntity7.UID_ENG_NAME;
												}

												if (_AttributeMapping.Name=="VARIABLE.UID_CHS_NAME") {
													_UID02001BV.ZZWxf["VARIABLE.UID_CHS_NAME"]=_NewEntity7.UID_CHS_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.BASE_COLUMN_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.BASE_COLUMN_NAME"]=_NewEntity7.BASE_COLUMN_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.BASE_TABLE_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.BASE_TABLE_NAME"]=_NewEntity7.BASE_TABLE_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.LNK_COLUMN_NAME") {
													_UID02001BV.ZZWxf["ZUPRGDTM.LNK_COLUMN_NAME"]=_NewEntity7.LNK_COLUMN_NAME;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.OPT_CODE") {
													_UID02001BV.ZZWxf["ZUPRGDTM.OPT_CODE"]=_NewEntity7.OPT_CODE;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VERFY") {
													_UID02001BV.ZZWxf["ZUPRGDTM.RELY_VERFY"]=_NewEntity7.RELY_VERFY;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_DEFAULT") {
													_UID02001BV.ZZWxf["ZUPRGDTM.RELY_DEFAULT"]=_NewEntity7.RELY_DEFAULT;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.RELY_VIEW") {
													_UID02001BV.ZZWxf["ZUPRGDTM.RELY_VIEW"]=_NewEntity7.RELY_VIEW;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.NEW_LINE") {
													_UID02001BV.ZZWxf["ZUPRGDTM.NEW_LINE"]=_NewEntity7.NEW_LINE;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.NEW_CELL") {
													_UID02001BV.ZZWxf["ZUPRGDTM.NEW_CELL"]=_NewEntity7.NEW_CELL;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.ROWS_SPAN") {
													_UID02001BV.ZZWxf["ZUPRGDTM.ROWS_SPAN"]=_NewEntity7.ROWS_SPAN;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.COLS_SPAN") {
													_UID02001BV.ZZWxf["ZUPRGDTM.COLS_SPAN"]=_NewEntity7.COLS_SPAN;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.ACTIVE_BIT") {
													_UID02001BV.ZZWxf["ZUPRGDTM.ACTIVE_BIT"]=_NewEntity7.ACTIVE_BIT;
												}

												if (_AttributeMapping.Name=="ZUPRGDTM.LINE_REVEAL") {
													_UID02001BV.ZZWxf["ZUPRGDTM.LINE_REVEAL"]=_NewEntity7.LINE_REVEAL;
												}

								}
								_UID02001BV.ZZWxf.Reference=cMsg;
								_UID02001BV.ZZWxf.Operation="F";
							}

						}

						_UID02001BV.ZZWxf.MoveNext();
					}

					_UID02001BV.ZZWxf.Variable("SUCCESS",_SUCCESS);
					_UID02001BV.ZZWxf.Variable("FAILURE",_FAILURE);

					if (_FAILURE==0 && _SUCCESS>0) {
						this.Trans.Commit();
					}

				}
			}
		}

		public override void OnDelete()
		{
			int _SUCCESS=0;
			int _FAILURE=0;

			UID02001BE _NewEntity=new UID02001BE();

			if (_UID02001BV.lnk_MODE=="B") {
				_UID02001BV.ZZWxf.MoveFirst();
				while (!_UID02001BV.ZZWxf.EOF)
				{
					VContexts _VContexts=new VContexts();

					_VContexts.setValue("UDEF_CODE","");

					if (_UID02001BV.ZZWxf.PK_DATA!="" && _UID02001BV.ZZWxf.Operation=="f"  ) {

						Spliter _PK_Spliter      = new Spliter(_UID02001BV.ZZWxf.PK_DATA);
						_PK_Spliter.Separator    = '|';
						_PK_Spliter.Separatorb   = '=';
						_PK_Spliter.DecodeBase64 = true;
						_PK_Spliter.Split();

						UID02001BE _Entity=_UID02001BV.Entity;

								_Entity.UID_DT=_PK_Spliter["UID_DT"];

										_Entity.UID_CODE=_UID02001BV.ZZPanels["UID02001A","PK_UID_CODE"];

						_NewEntity=_UID02001BM.Delete(_UID02001BV.Entity);

						if (_NewEntity.Exceptions.Count==0) {
							_SUCCESS++;
						}else{
							_FAILURE++;
						}
					}
					_UID02001BV.ZZWxf.MoveNext();
				}

				if (_SUCCESS>0 && _FAILURE==0 ) {
					//this.Empty();
					this.OnRetrieve("");

					this.Trans.Commit();

				}

				ZZTrace.Debug(ZFILE_NAME,"_SUCCESS = "+_SUCCESS);
				ZZTrace.Debug(ZFILE_NAME,"_FAILURE = "+_FAILURE);

				ZZTrace.Debug(ZFILE_NAME,"_UID02001BV.ZZEventStatus = "+_UID02001BV.ZZEventStatus);
				ZZTrace.Debug(ZFILE_NAME,"_UID02001BV.ZZEventStage = "+_UID02001BV.ZZEventStage);

				if (_SUCCESS>=0 && _FAILURE==0 ) {
					_UID02001BV.ZZVIEW_STATUS_CODE = _UID02001BV.ZZEventStatus;
					_UID02001BV.ZZVIEW_STAGEU_CODE = _UID02001BV.ZZEventStage;
				}

			}else{
				_NewEntity=_UID02001BM.Delete(_UID02001BV.Entity);

				ZZTrace.Debug(ZFILE_NAME,"_Delete1");
				
				if (_NewEntity.Exceptions.Count==0) {

					ZZTrace.Debug(ZFILE_NAME,"_Delete2");
					this.OnRetrieve("");

					ZZTrace.Debug(ZFILE_NAME,"_Delete5");
					this.Trans.Commit();

					_UID02001BV.ZZVIEW_STATUS_CODE = _UID02001BV.ZZEventStatus;
					_UID02001BV.ZZVIEW_STAGEU_CODE = _UID02001BV.ZZEventStage;
				}
			}

			_UID02001BV.Exceptions=_NewEntity.Exceptions;

		}

		public override void OnUserDef(string cAction_Code,string cDefined_Code)
		{
			VContexts _VContexts=new VContexts();

			_VContexts.setValue("UDEF_CODE",cDefined_Code);
			_VContexts.setValue("Events",cAction_Code);
			_VContexts.setValue("STATUS_CODE",_UID02001BV.ZZVIEW_STATUS_CODE);
			_VContexts.setValue("Sender", "UID02001B");

			UID02001BE _NewEntity=_UID02001BM.UserDefine(_VContexts,_UID02001BV.Entity);

			if (_NewEntity.Exceptions.Count==0) {
				_UID02001BV.Entity             = _NewEntity;
				_UID02001BV.ZZVIEW_STATUS_CODE = _UID02001BV.ZZEventStatus;
				_UID02001BV.ZZVIEW_STAGEU_CODE = _UID02001BV.ZZEventStage;

				ZZTrace.Debug(ZFILE_NAME,cAction_Code+","+cDefined_Code);
			}
			_UID02001BV.Exceptions=_NewEntity.Exceptions;
		}

		public override void Process()
		{
			try
			{
				checked
				{

					this.Trans                = new StreamContext(this.DbName);
					this.Trans.Writeable      = true;
					_UID02001BM.Trans       = this.Trans;
					_UID02001BM.ZZLOGON_SSD = _UID02001BV.ZZLOGON_SSD;
					_UID02001BM.Initialize();

					base.Process();

					ZZTrace.Error(ZFILE_NAME,"PK_XX");

				}
			}
			catch (LogisticException ErrMsg)
			{
				_UID02001BV.Exceptions.Add(ErrMsg);

				string cMessage = "Message=[" + ErrMsg.Message + "]" + "\nSource=[" + ErrMsg.Source + "]\nStackTrace=[" + ErrMsg.StackTrace + "]\nTargetSite=[" + ErrMsg.TargetSite + "]";

				ZZTrace.Error(ZFILE_NAME,cMessage);
				
				ZZTrace.Error(ZFILE_NAME,ErrMsg);

				try
				{
					this.Trans.RollBack();
				}
				catch (Exception Ex)
				{
					cMessage = "Message=[" + ErrMsg.Message + "]" + "\nSource=[" + ErrMsg.Source + "]\nStackTrace=[" + ErrMsg.StackTrace + "]\nTargetSite=[" + ErrMsg.TargetSite + "]";

					ZZTrace.Error(ZFILE_NAME,cMessage);
					
					ZZTrace.Error(ZFILE_NAME,Ex);
				}

			}
			catch (Exception e)
			{
				string cMessage2 = "Message=[" + e.Message + "]" + "\nSource=[" + e.Source + "]\nStackTrace=[" + e.StackTrace + "]\nTargetSite=[" + e.TargetSite + "]";

				ZZTrace.Error(ZFILE_NAME,cMessage2);
				
				_UID02001BV.Exceptions.Add(new LogisticException("UID02001B","SystemError",""));
				ZZTrace.Error(ZFILE_NAME,e);
				try
				{
					this.Trans.RollBack();
				}
				catch (Exception)
				{
				}
			}
			finally
			{
				this.Trans.Close();
				ZZTrace.Debug(ZFILE_NAME,"Close-Trans");
			}
		}

		public override void Process_Aft()
		{

			_UID02001BM.DbName      = this.DbName;
			_UID02001BM.Trans       = this.ReadMode;
			_UID02001BM.ZZLOGON_SSD = _UID02001BV.ZZLOGON_SSD;

			VContexts _VContexts=new VContexts();

			_VContexts=_UID02001BV.CellsPanel.VIEW_STATUS_DATA;
			_VContexts.setValue("LOOKUP_DATA",_UID02001BV.ZZPanels["UID02001B","lookup"]);

			_UID02001BM.Search(_VContexts, _UID02001BV.Entity);
			_UID02001BV.CellsPanel.VIEW_STATUS_DATA=_VContexts;


			_UID02001BV.ZZPanels["UID02001B","view_status"]=_UID02001BV.CellsPanel.VIEW_STATUS_DATA.ToString();
		}

		public override void OnInit(HttpContext  objHttpContext)		
		{

			_UID02001BM = new UID02001BM();
			_UID02001BV = new UID02001BV();

			_UID02001BV.OnInit(objHttpContext);
			this.DbName                = _UID02001BV.DbName;
			this.ZZEventArgs           = _UID02001BV.ZZEventArgs;
			this.ZZVIEW_STATUS_CODE    = _UID02001BV.ZZVIEW_STATUS_CODE;
			this.ZZLOGON_LANG = _UID02001BV.ZZLOGON_LANG;

			this.ReadMode=_UID02001BV.Trans;

			_UID02001BM.ZZLOGON_ID   = _UID02001BV.ZZLOGON_ID;
			_UID02001BM.ZZLOGON_LANG = _UID02001BV.ZZLOGON_LANG;
			_UID02001BV.APP_PATH     = this.APP_PATH;
			_UID02001BV.setValue();
		}

		public override void Render(HtmlTextWriter objTextWriter)
		{
			try
			{
				if (_UID02001BV.ZZLOGON_MODE=="B")
				{
					_UID02001BV.ZZWxf.Variable("lnk_RW_NO",_UID02001BV.lnk_RW_NO);

					objTextWriter.WriteLine(_UID02001BV.ZZWxf.ToString());
				}else{
					_UID02001BV.getValue();
					_UID02001BV.Render(objTextWriter);
				}
			}
			finally
			{
				this.ReadMode.Close();
				ZZTrace.Debug(ZFILE_NAME,"Close-ReadMode");
			}

		}

		const  string ZFILE_NAME   ="UID02001BC";
		const  string MUKI_EDITION ="MIN";

		private UID02001BM      _UID02001BM;
		private UID02001BV      _UID02001BV;

#region screen element
#endregion
	}
}
